package Extends.DuoTai.test1;

import java.sql.SQLOutput;

public class Test1 {
    public static void main(String[] args) {
        student s=new student();
        s.setAge(17);
        s.setName("张三");
        teacher t=new teacher();
        t.setAge(17);
        t.setName("张三");
        administrtor ad=new administrtor();
        ad.setAge( 29);
        ad.setName("lisi");
    register(s);
        register(t);
        register(ad);
    }
    public static void register(person p)//类似 person p=new person();的形式
    {
        p.show();
    }
    //既可以接受老师，又可以接受学生，还可以接受管理员
    //只可以将参数写成父类的形式。

    public static class person{
       private String name;
        private int age;

        public person() {
        }

        public person(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
        public void show(){
            System.out.println(name+","+age);
        }
    }

    public static class student extends person {
        public void show() {
            System.out.println("学生的信息为：" + getName() + "," + getAge());
        }
    }
    public static class administrtor extends person{
        public void show(){
            System.out.println("老师的信息为："+getName()+","+getAge());
        }
    }

    public static class teacher extends person{
        public void show(){
            System.out.println("管理员的信息为："+getName()+","+getAge());
        }
    }
}
